import { useEffect, useState } from 'react'

function usePosition() {
  let [x, setX] = useState(110)
  let [y, setY] = useState(110)

  useEffect(() => {
    function move(e) {
      setX(e.clientX)
      setY(e.clientY)
    }
    window.addEventListener('mousemove', move)
    return () => {
      window.removeEventListener('mousemove', move)
    }
  }, [])
  return {
    x,
    y,
  }
}

export default usePosition
